<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>基础</title>
    <style>
        canvas {
            background: #ccc;
        }
    </style>
</head>
<body>
<canvas width="500" height="400" id="canvas">
    您的浏览器不支持canvas，请更新！
</canvas>
</body>
<script>
    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext("2d");
    ctx.fillStyle="red";
    ctx.beginPath();
   ctx.moveTo(200,200);
   ctx.lineTo(250,300);
   ctx.lineTo(300,200);
    //ctx.arc(250,200,50,0,Math.PI)
    /*ctx.closePath();*/
    //ctx.stroke();
    ctx.fill();

</script>
</html>